#version 300 es
precision mediump float;
uniform sampler2D sTexture ;
uniform int uBoolean ;

in vec4 vAmbient;
in vec4 vDiffuse;
in vec4 vSpecular;

in vec4 vAmbientF;   //环境光
in vec4 vDiffuseF;   //散射光
in vec4 vSpecularF;  //镜面光

in vec2 vTexCoors ;

out vec4 fragColor ;

void main(){
        if(uBoolean != 1 ){
        vec4 finalColor=vec4(0.9,0.9,0.9,1.0);
        if(gl_FrontFacing){
            fragColor = finalColor*vAmbient+finalColor*vSpecular+finalColor*vDiffuse;
        }else{
            fragColor = finalColor*vAmbientF+finalColor*vSpecularF+finalColor*vDiffuseF;
        }

        }else{
        vec4 finalColor = texture(sTexture , vTexCoors) ;
        if(gl_FrontFacing){
            fragColor = finalColor*vAmbient+finalColor*vSpecular+finalColor*vDiffuse;
        }else{
            fragColor = finalColor*vAmbientF+finalColor*vSpecularF+finalColor*vDiffuseF;
        }
        }
}